package com.housesales.web;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import module.BasicBanKuai;
import module.HousePhoto;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import bussinessService.basicbussinessService;
import bussinessService.impl.HousePhotoBussinessServiceImpl;
import domain.vo.BlockQueryObject;
import domain.vo.BlockVO;
import domain.vo.HousePhotoQueryObject;
import domain.vo.HousePhotoVO;
import domain.vo.JSONObject;

/**
 * 
* @ClassName: HousePhotoController 
* @Description: 房屋图片MVC
* @author chenchao
* @date 2014年1月23日 下午3:39:38 
*
 */
@Controller
@RequestMapping("/photo")
public class HousePhotoController {
	private Logger logger = Logger.getLogger(HousePhotoController.class.getName());
	
	/**
	 * 板块业务层实现类
	 */
	private basicbussinessService<HousePhoto,HousePhotoVO>  hpBSI = new HousePhotoBussinessServiceImpl();
	
	@RequestMapping("/getPhotoJson")
	public @ResponseBody JSONObject<HousePhotoVO> getBlocksJson(@RequestParam("houseId") String houseId) {
		JSONObject<HousePhotoVO> jsonObject = new JSONObject<HousePhotoVO>();
		HousePhotoQueryObject hpQO = new HousePhotoQueryObject();
		hpQO.setHouseId(houseId);
		try {
			List<HousePhotoVO> tempVOS = new ArrayList<HousePhotoVO>(); 
			tempVOS = hpBSI.getObjectByQueryObject(hpQO);
			jsonObject.setTotal(tempVOS.size());
			jsonObject.setRows(tempVOS);
		} catch (SQLException e) {
			e.printStackTrace();
			logger.error(e.getMessage());
		}
		return jsonObject;
	}
	
}
